<?php
include 'connect.php';
session_start();
//接收用户名接收我的收藏里点击预约后传递过来的数据
$house=$_SESSION['house'];
$username=$_SESSION['username'];
$title=$_GET['title'];
$price=$_GET['price'];
$jiegou=$_GET['jiegou'];
$mianji=$_GET['mianji'];
$louceng=$_GET['louceng'];
$address=$_GET['address'];
$fdname=$_GET['fdname'];
$img=$_GET['img'];

//插入语句,点击立即预约后把用户名和房源的一些信息放入 reserve 表
    $result = mysqli_query($link,"insert into reserve(username,title,price,jiegou,mianji,louceng,address,fdname,img,state)values
('$username','$title','$price','$jiegou','$mianji','$louceng','$address','$fdname','$img','待处理')");

//用户预约成功后跳转到我的预约查看预约状态
if ($result){
    echo '
    <script src="layui-v2.6.8/layui/layui.js"></script>
    <link rel="stylesheet" href="layui-v2.6.8/layui/css/layui.css">
    <div style="margin: 40px auto;width: 500px;height: 100px">
        <i class="layui-icon layui-icon-face-smile-fine" style="font-size: 30px; color: #1E9FFF;"></i>
        <span style="display: inline-block;font-size: 24px;color: #1E9fff">预约成功,正在返回</span>
    </div>
          ';
    header('refresh:0.5;url=userreservetow.php');
    //否则失败则跳转到我的收藏页面
}else{
    echo '
    <script src="layui-v2.6.8/layui/layui.js"></script>
    <link rel="stylesheet" href="layui-v2.6.8/layui/css/layui.css">
    <div style="margin: 40px auto;width: 500px;height: 100px">
        <i class="layui-icon layui-icon-face-surprised" style="font-size: 30px; color: #1E9FFF;"></i>
        <span style="display: inline-block;font-size: 24px;color: #1E9fff">预约失败,正在返回</span>
    </div>
          ';
    header('refresh:0.5;url=userreserveList.php');
}